home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / FireMan.swf / scripts / frame_1055 / PlaceObject2_362_25 / CLIPACTIONRECORD onClipEvent(enterFrame).as next >
Text File  |  2008-09-12  |  3KB  |  133 lines

  1. onClipEvent(enterFrame){
  2.    function doexplode()
  3.    {
  4.       myColor.setTransform(myColorNormal);
  5.       this.gotoAndStop("death");
  6.    }
  7.    function dorespawn()
  8.    {
  9.       currentdamage = 0;
  10.       hitted = false;
  11.       flashing = false;
  12.       timerdamage = 0;
  13.       death = false;
  14.       this.gotoAndStop("standing");
  15.       idle = true;
  16.       attack = preattack = attacking = false;
  17.       _X = xi;
  18.       _Y = yi;
  19.       shoot = new Sound();
  20.       shoot.attachSound("barrelshoot");
  21.    }
  22.    function drawframe()
  23.    {
  24.       if(idle)
  25.       {
  26.          this.gotoAndStop("standing");
  27.       }
  28.       if(attacking)
  29.       {
  30.          this.gotoAndStop("attack");
  31.       }
  32.    }
  33.    xi -= heroe.scrollspeed;
  34.    _X = _X - heroe.scrollspeed;
  35.    yi -= heroe.vscrollspeed;
  36.    _Y = _Y - heroe.vscrollspeed;
  37.    _visible = false;
  38.    hitable = this.hitTest(_parent.mascara);
  39.    if(hitable)
  40.    {
  41.       _visible = true;
  42.       if(this.sprite.hotzone.hitTest(heroe.sprite.hotzone))
  43.       {
  44.          heroe.damage = 3;
  45.          heroe.hitted = true;
  46.       }
  47.       if(this.sprite.hotzone.hitTest(_parent.shoot1) && hitable)
  48.       {
  49.          hitted = true;
  50.          _root.shoot1.impact = true;
  51.          _root.hitted.start();
  52.       }
  53.       if(timerdamage == 0 && hitted)
  54.       {
  55.          timerdamage = FLASHTIME;
  56.          currentdamage += DAMAGE;
  57.       }
  58.       if(timerdamage > 0)
  59.       {
  60.          flashing = true;
  61.          timerdamage % 3 != 0 ? myColor.setTransform(myColorNormal) : myColor.setTransform(myColorTransform);
  62.          timerdamage--;
  63.       }
  64.       if(flashing && timerdamage == 0)
  65.       {
  66.          flashing = false;
  67.          myColor.setTransform(myColorNormal);
  68.          hitted = false;
  69.       }
  70.       if(currentdamage >= MAXDAMAGE)
  71.       {
  72.          myColor.setTransform(myColorTransform);
  73.          delete shoot;
  74.          death = true;
  75.       }
  76.       if(death)
  77.       {
  78.          _root.shoot1.impact = false;
  79.          doexplode();
  80.       }
  81.    }
  82.    if(!death)
  83.    {
  84.       if(idle)
  85.       {
  86.          if(Math.abs(heroe._x - _X) <= 140 && Math.abs(heroe._y - _Y) <= 220)
  87.          {
  88.             attack = attacking = false;
  89.             idle = false;
  90.             preattack = true;
  91.             timer = DELAY;
  92.          }
  93.       }
  94.       if(preattack)
  95.       {
  96.          timer--;
  97.          if(!timer)
  98.          {
  99.             preattack = false;
  100.             attack = true;
  101.          }
  102.       }
  103.       if(attack && !attacking)
  104.       {
  105.          attacking = true;
  106.          this.attachMovie("bullet","b1",1);
  107.          this.attachMovie("bullet","b2",2);
  108.          shoot.start();
  109.          b1.control.dx = SPEED;
  110.          b1.control.dy = -1 * SPEED;
  111.          b1._x = -12;
  112.          b1._y = -14;
  113.          b2.control.dx = -1 * SPEED;
  114.          b2.control.dy = -1 * SPEED;
  115.          b2._x = 12;
  116.          b2._y = -14;
  117.       }
  118.       if(attacking)
  119.       {
  120.          if(!b1.hitTest(_root.mascara) && !b2.hitTest(_root.mascara))
  121.          {
  122.             attacking = attack = preattack = false;
  123.             idle = true;
  124.          }
  125.       }
  126.       drawframe();
  127.    }
  128.    else if(!_root.mascara.hitTest(xi,yi))
  129.    {
  130.       dorespawn();
  131.    }
  132. }
  133.